
function reactive( obj ){
    return createReactiveObject(obj)
}

function createReactiveObject(obj){
    const proxy = new Proxy(obj, {
        get : function (obj, key, receiver= {}){
            const res = Reflect.get(obj, key, receiver)
            // 调用track()，收集依赖
            return res
        },
        set : function(obj, key, value, receiver = {} ){
            // 此时的receiver为this，即为proxy代理
            const result = Reflect.set(obj, key, value, receiver)
            let oldValue = obj[key]
            if(oldValue !== value){
                // 调用trigger() ，触发更新
            }
            
            return result
        },
        
    })
    return proxy
}

let obj = {a : 1}
let objProxy = reactive(obj)
objProxy.a = 2
console.log(objProxy.a)